In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
There are two extremely high trees in Byteotia, and each of them has many hollows scooped out in its trunk, one under another. Once upon a time very fast birds decided to inhabit the hollows. Some of them know each other and therefore would like to be able to pay one another visits in their hollows. The birds fly very fast and always along a straight line. In order to avoid the danger of collision they decided to quarter in a way that:
In addition, the birds would like to live as low as possible. So in each tree they inhabit a certain number of lower hollows. There are more hollows in each tree than there are birds in whole.
It is well-known that birds have very small brains. That's why they have asked you - a respected ornithologist - to help them find out in how many ways they can quarter in the hollows.
Write a programme that:
In the first line of the standard input there are three integers written , and , denoting respectively: the number of birds, the number of distinct pairs of birds knowing each other and the number that is to be used when giving result (see: Output), , , . The birds are numbered from to . In the following lines the pairs of birds knowing each other are given, one per line. In the line no. two integers and , separated by a single space, are written (, ). These are the numbers of the familiar birds. Each (unordered) pair of familiar birds is given exactly once.
Let denote the number of distinct quarterings of birds satisfying the given constraints. Your programme should write one integer in the first line of the standard output: the remainder of division of by . If no quartering exists the correct result is .
For the input data:
3 2 10 1 2 1 3
the correct result is:
4
Task author: Jakub Radoszewski.